/*
 * chunkserver-journal-entry.h
 *
 *  Created on: Jun 17, 2016
 *      Author: zhangzm
 */

#ifndef CHUNKSERVER_JOURNAL_CHUNKSERVER_JOURNAL_ENTRY_H_
#define CHUNKSERVER_JOURNAL_CHUNKSERVER_JOURNAL_ENTRY_H_

#include "../module-client/disk-cache/cache-entry.h"

struct ChunkServerJournalEntry;
struct ChunkServerJournalEntry *new_chunk_journal_entry();
void del_chunk_journal_entry(struct ChunkServerJournalEntry *entry);
void lock_chunk_entry(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index);
void unlock_chunk_entry(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index);
int insert_range(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index, uint32_t begin, uint32_t len, uint64_t pos, uint64_t range_version, time_t time);
int lookup_range(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index, uint32_t begin, uint32_t len, uint32_t *rbegin, uint32_t *rend, uint64_t *rpos);
int lookup_multy(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index, uint32_t begin, uint32_t len, struct Segment **os);
int clear_range(struct ChunkServerJournalEntry *entry, uint32_t volumeid, uint32_t index, uint64_t begin, uint32_t len, uint64_t range_version, time_t time);
int get_chunk_version_range(struct ChunkServerJournalEntry* entry, uint32_t volumeid, uint32_t index, uint64_t *start_version, uint64_t *end_version);

#endif /* CHUNKSERVER_JOURNAL_CHUNKSERVER_JOURNAL_ENTRY_H_ */
